/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NieuwSpel.java
 *
 * Created on 17-mei-2009, 11:51:35
 */

package gui;

import Toepen.LoungeFacade.ILoungeFacade;
import java.net.InetAddress;
import org.jdesktop.application.Action;
import javax.swing.JOptionPane;

/**
 * Dialoogvenster waarmee een nieuw spel aangemaakt kan worden
 * @author LucasD
 */
public class NieuwSpelDialog extends javax.swing.JDialog {
    private ILoungeFacade loungeFacade;
    private GUILounge loungeGui;

    /** Creates new form NieuwSpel */
    public NieuwSpelDialog(java.awt.Frame parent, boolean modal, ILoungeFacade facade, GUILounge loungeGui) {
        super(parent, modal);
        this.loungeFacade = facade;
        this.loungeGui = loungeGui;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        chkVuileWas = new javax.swing.JCheckBox();
        chkBlindKloppen = new javax.swing.JCheckBox();
        chkKansOpToep = new javax.swing.JCheckBox();
        chkKoningsToepen = new javax.swing.JCheckBox();
        chkVijfKruizen = new javax.swing.JCheckBox();
        textNaam = new javax.swing.JTextField();
        comboAantal = new javax.swing.JComboBox();
        btnAanmaken = new javax.swing.JButton();
        butAnnuleren = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(gui.GUIApp.class).getContext().getResourceMap(NieuwSpelDialog.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.setName("jPanel1"); // NOI18N

        chkVuileWas.setText(resourceMap.getString("chkVuileWas.text")); // NOI18N
        chkVuileWas.setEnabled(false);
        chkVuileWas.setName("chkVuileWas"); // NOI18N

        chkBlindKloppen.setText(resourceMap.getString("chkBlindKloppen.text")); // NOI18N
        chkBlindKloppen.setEnabled(false);
        chkBlindKloppen.setName("chkBlindKloppen"); // NOI18N

        chkKansOpToep.setText(resourceMap.getString("chkKansOpToep.text")); // NOI18N
        chkKansOpToep.setEnabled(false);
        chkKansOpToep.setName("chkKansOpToep"); // NOI18N

        chkKoningsToepen.setText(resourceMap.getString("chkKoningsToepen.text")); // NOI18N
        chkKoningsToepen.setEnabled(false);
        chkKoningsToepen.setName("chkKoningsToepen"); // NOI18N

        chkVijfKruizen.setText(resourceMap.getString("chkVijfKruizen.text")); // NOI18N
        chkVijfKruizen.setEnabled(false);
        chkVijfKruizen.setName("chkVijfKruizen"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chkVuileWas)
                    .addComponent(chkBlindKloppen)
                    .addComponent(chkKansOpToep))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 107, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chkKoningsToepen)
                    .addComponent(chkVijfKruizen))
                .addContainerGap(71, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chkVuileWas)
                    .addComponent(chkKoningsToepen))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chkBlindKloppen)
                    .addComponent(chkVijfKruizen))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(chkKansOpToep)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        textNaam.setText(resourceMap.getString("textNaam.text")); // NOI18N
        textNaam.setName("textNaam"); // NOI18N

        comboAantal.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "4" }));
        comboAantal.setName("comboAantal"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(gui.GUIApp.class).getContext().getActionMap(NieuwSpelDialog.class, this);
        btnAanmaken.setAction(actionMap.get("maakSpelAan")); // NOI18N
        btnAanmaken.setText(resourceMap.getString("btnAanmaken.text")); // NOI18N
        btnAanmaken.setName("btnAanmaken"); // NOI18N

        butAnnuleren.setAction(actionMap.get("sluitScherm")); // NOI18N
        butAnnuleren.setText(resourceMap.getString("butAnnuleren.text")); // NOI18N
        butAnnuleren.setName("butAnnuleren"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel3)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 93, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(comboAantal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(textNaam, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnAanmaken)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 216, Short.MAX_VALUE)
                        .addComponent(butAnnuleren)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(textNaam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(comboAantal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel3)
                .addGap(11, 11, 11)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAanmaken)
                    .addComponent(butAnnuleren))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    @Action
    public void maakSpelAan() {
        try
        {
            /*loungeGui.setEigenSpel(loungeFacade.maakSpelAan(textNaam.getText(), 4, loungeGui.getIngelogdeGebruiker(), chkBlindKloppen.isSelected(), chkKansOpToep.isSelected(), chkKoningsToepen.isSelected(), chkVijfKruizen.isSelected(), chkVuileWas.isSelected()));*/
            loungeFacade.maakSpelAan(InetAddress.getLocalHost().getHostAddress(), textNaam.getText(), 4, loungeGui.getIngelogdeGebruiker(), chkBlindKloppen.isSelected(), chkKansOpToep.isSelected(), chkKoningsToepen.isSelected(), chkVijfKruizen.isSelected(), chkVuileWas.isSelected());
            sluitScherm();
        }
        catch (Exception ex)
        {
            JOptionPane.showMessageDialog(this, "Er is al een spel met deze naam!", "Fout!", JOptionPane.INFORMATION_MESSAGE);
        }
        //sluitScherm();
    }

    @Action
    public void sluitScherm() {
        setVisible(false);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAanmaken;
    private javax.swing.JButton butAnnuleren;
    private javax.swing.JCheckBox chkBlindKloppen;
    private javax.swing.JCheckBox chkKansOpToep;
    private javax.swing.JCheckBox chkKoningsToepen;
    private javax.swing.JCheckBox chkVijfKruizen;
    private javax.swing.JCheckBox chkVuileWas;
    private javax.swing.JComboBox comboAantal;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField textNaam;
    // End of variables declaration//GEN-END:variables

}
